package core.io;

import utils.Assert;

import java.io.*;

/**
 * Created by ZhaiGuaili on 2018/7/5.
 */
public class FileSystemResource implements Resource {

    private String filePath;
    private File file;


    public FileSystemResource(String filePath){
        Assert.notNull(filePath,"filePath is null");
        this.filePath = filePath;
        this.file = new File(filePath);

    }


    @Override
    public InputStream getInputStream() throws IOException{
        FileInputStream stream = null;
        try{
          stream = new FileInputStream(this.file);
        }catch (FileNotFoundException e){
            e.getMessage();
        }
        return  stream;

    }

    @Override
    public String getDescribtion() {
        return "file "+this.file.getAbsolutePath();
    }
}
